package com.lanou.dllo.baisibudejie.activity;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.ImageView;
import android.widget.TextView;

import com.lanou.dllo.baisibudejie.R;
import com.lanou.dllo.baisibudejie.db.MySQLiteLoginUtil;
import com.lanou.dllo.baisibudejie.db.entity.User;

/**
 * Created by dllo on 15/10/22.
 */
public class ReginsteredActivity extends Activity implements View.OnClickListener {

    private ImageView register_finishIv;
    private TextView register_hasNumberTv,register_qqTv;
    private EditText register_phono_numberEt,register_pswEt;
    private Button registerBtn;
    private MySQLiteLoginUtil loginUtil;


    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_reginstered);
        loginUtil = new MySQLiteLoginUtil(this);
        initView();//页面初始化方法
    }

    /**
     * 页面初始化方法
     */
    private void initView() {

        register_finishIv = (ImageView) findViewById(R.id.register_finishIv);//返回按钮
        register_finishIv.setOnClickListener(this);
        register_hasNumberTv = (TextView) findViewById(R.id.register_hasNumberTv);//已有账号？
        register_hasNumberTv.setOnClickListener(this);
        register_phono_numberEt = (EditText) findViewById(R.id.register_phono_numberEt);//账号输入框
        register_pswEt = (EditText) findViewById(R.id.register_pswEt);//密码输入框
        registerBtn = (Button) findViewById(R.id.registerBtn);//注册按钮
        registerBtn.setOnClickListener(this);
        register_qqTv = (TextView) findViewById(R.id.register_qqTv);//QQ登录
        register_qqTv.setOnClickListener(this);

    }

    @Override
    public void onClick(View v) {
        switch (v.getId()) {
            case R.id.register_finishIv://返回按钮
                finish();
                break;
            case R.id.register_hasNumberTv://已有账号？
                Intent intent_hasNumber = new Intent(this,LoginActivity.class);
                startActivity(intent_hasNumber);
                finish();
                break;
            case R.id.registerBtn://注册按钮
                User user = new User();
                user.setName(register_phono_numberEt.getText().toString());
                user.setPassword(register_pswEt.getText().toString());
                loginUtil.saveDatasToDataBase(user);
//                Intent intent = new Intent(this,LoginActivity.class);
//                startActivity(intent);
                finish();
                break;
            case R.id.register_qqTv://QQ登录

                break;

        }
    }
}
